import { UserModel } from "../Model/userModel.js"

export const addUserDao = async(user)=>{
    return await UserModel.insertOne(user)
}

export const findUserDao = async(username)=>{
    // find===>Array返回的是一个数组所以应该使用findOne
    return await UserModel.findOne({username})
}

export const updateUserDao = async (username,updateObj) => {
    return await UserModel.findOneAndUpdate({
        username
    },{
        $set:{...updateObj}
    },{new:true})

}

export const findUserByIdDao = async(id) => {
    return await UserModel.findById(id)
}